#include "texture.hpp"

bool ILTex2D(const wchar_t* file_name,GLuint textureID)
{
	ILuint m_imageID = 0;
	ILboolean success(0);
	//GLuint textureID;
	ilInit();
	ilGenImages(1,&m_imageID);

	ilBindImage(m_imageID);
	//ilEnable(IL_ORIGIN_SET);
	//ilOriginFunc(IL_ORIGIN_LOWER_LEFT);

	success = ilLoadImage(file_name);

	if(!success)
	{
		//load fail
		ilDeleteImages(1,&m_imageID);
		return false;
	}

	printf("Load texture : %s success \n", file_name);

	ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE);

	//glGenTextures(1,&textureID);
	glBindTexture(GL_TEXTURE_2D,textureID);
	glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,ilGetInteger(IL_IMAGE_WIDTH),ilGetInteger(IL_IMAGE_HEIGHT),0,GL_RGBA,GL_UNSIGNED_BYTE,ilGetData());

	return true;



}
